package com.example.alibabanacosconfig.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @createBy guoqiang
 * @createTime 2019/4/3
 * @describe
 */
@RestController
@RequestMapping("/config")
@RefreshScope
@Tag(name="配置中心")
public class ConfigController {
    private static final Logger log = LoggerFactory.getLogger(ConfigController.class);
    @Value("${spring.cloud.nacos.config.serveraddr:空addr}")
    String addr;
    @Value("${spring.cloud.nacos.config.prefix:空prefix}")
    String prefix;
    @Value("${spring.cloud.nacos.config.group:空group}")
    String group;
    @Value("${spring.cloud.nacos.config.namespace:空namespace}")
    String namespace;

    @GetMapping("/addr")
    @Operation(summary ="配置中心-获取addr")
    public  String addr(){
        //测试默认的格式的配置文件 .properties
        return  addr;
    }
    @GetMapping("/prefix")
    @Operation(summary ="配置中心-获取prefix")
    public  String prefix(){
        //测试yaml格式的配置文件 .yml
        return  prefix;
    }
    @GetMapping("/group")
    @Operation(summary ="配置中心-获取group")
    public  String group(){
        return  group;
    }
    @GetMapping("/namespace")
    @Operation(summary ="配置中心-获取namespace")
    public  String namespace(){
        return  namespace;
    }
}
